﻿//-----------------------------------------------------------------------
// <copyright file="AccountHelper.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Common.Repository.Interfaces.Repositories;
using GateShift.Services.GameData.Entities;

#endregion

namespace GateShift.Testing.Services.GameData.Helpers
{
    /// <summary>
    /// Static Unit Test Helper Class for Account Entities
    /// </summary>
    internal static class AccountHelper
    {
        /// <summary>
        /// Creates an account ready to save to the database
        /// </summary>
        /// <returns>Account with unique default values</returns>
        public static Account CreateAccount()
        {
            Account account = new Account
                                  {
                                      AccountName = Guid.NewGuid().ToString(),
                                      DateCreated = DateTime.UtcNow,
                                      EmailAddress = Guid.NewGuid().ToString().Replace("-", string.Empty) + "@example.com",
                                      Locked = false,
                                      Password = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 },
                                      PasswordSalt = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }
                                  };

            return account;
        }

        /// <summary>
        /// Creates an account ready pre-saved to the database
        /// </summary>
        /// <returns>Account with unique default values</returns>
        public static Account CreateDBAccount()
        {
            Account account = CreateAccount();

            DBHelper.Provider.GetRepository<IAccountRepository>().Save(account);

            return account;
        }
    }
}